<template>
	<view class="mainpadding">
		<view class="flexbetween margin_top6" @click="xbshow = true">
			<view class="sanshier xiaohui flexleft">{{$t('personInfo.xb')}}<text class="xiaohong">*</text></view>
			<view class="flexright">
				<view class="sanshier margin_right1">{{gender}}</view>
				<u-icon name="arrow-right"></u-icon>
			</view>
		</view>
		<view class="flexbetween margin_top6" @click="messageTime.timeShow=true">
			<view class="sanshier xiaohui flexleft">{{$t('personInfo.sr')}}<text class="xiaohong">*</text></view>
			<view class="flexright" style="width: 80%;">
				<input type="text" class="sanshier margin_right1 textright" disabled="" v-model="birthday"/>
				<u-icon name="arrow-right"></u-icon>
			</view>
		</view>
		<view class="flexbetween margin_top6">
			<view class="sanshier xiaohui flexleft">{{$t('personInfo.zy')}}<text class="xiaohong">*</text></view>
			<input type="text" class="sanshier textright" style="width: 80%;" :placeholder="$t('personInfo.qsr')" v-model="occupation"/>
		</view>
		<view class="margin_top6">
			<view class="sanshier xiaohui">{{$t('personInfo.zyxx')}}</view>
			<textarea class="sanshier margin_top" :placeholder="$t('personInfo.qsr')" style="width: 100%;height: 200rpx;" v-model="affection"></textarea>
		</view>
		<view class="mainpadding gudingdb">
			<view class="bigbtn" @click="setinfo">{{$t('personInfo.qr')}}</view>
		</view>
		<timePicker :messageTime="messageTime" @timeConfirm="timeConfirm"></timePicker>
		<!-- 选择性别 -->
		<u-picker :show="xbshow" :columns="xbcolumns" :title="$t('personInfo.xzxb')" @cancel="xbshow=false" @confirm="xbconfirm"></u-picker>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				xbshow: false,
				xbcolumns: [
					[this.$t('personInfo.nan'), this.$t('personInfo.nv')]
				],
				gender:"",
				occupation:"",
				birthday:"",
				affection:"",
				messageTime:{
					timeShow:false,
					title:this.$t('personInfo.xzcsny'),
					mode:"date",//date日期，datetime年月日时分秒，time时间，year-month年月
					minDate:"0"//最小时间
				}
				
			}
		},
		methods: {
			timeConfirm(e){
				this.birthday = e
			},
			// 性别
			xbconfirm(e) {
				this.xbshow = false
				if(e.value[0]==this.gender){
					return false
				}
				this.gender = e.value[0]
			},
			setinfo(data) {
				if(this.gender==""){
					httpRequest.toast(this.$t('personInfo.qxzxb'))
					return false
				}
				if(this.birthday==""){
					httpRequest.toast(this.$t('personInfo.qxznl'))
					return false
				}
				if(this.occupation==""){
					httpRequest.toast(this.$t('personInfo.qsrzy'))
					return false
				}
				httpRequest.request('/api/v1/users/editUser', 'POST', {
					sex:this.gender==this.$t('personInfo.nan')?0:1,
					birthday:this.birthday,
					occupation:this.occupation,
					affection:this.affection
				}).then(res => {
					if(res.code==200){
						uni.redirectTo({
							url: "/pages/index/pay?type=1"
						})
					}else{
						httpRequest.toast(res.msg)
					}
				})
			},
		}
	}
</script>

<style>

</style>
